const CompressionWebpackPlugin = require('compression-webpack-plugin')

module.exports = {
  productionSourceMap: false,
  configureWebpack: (config) => {
    // 生产环境下生效
    if (process.env.NODE_ENV === 'production') {
      // 配置删除 console.log
    //   config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true

      // 配置 gzip 压缩
      config.plugins.push(
        new CompressionWebpackPlugin({
          test: /\.js$|\.html$|\.css$/,
          threshold: 4096, // 超过4kb压缩
        })
      )
    }
  },
}
